import Vue from "vue";
import Vuex from "vuex";
import { reqPaging, reqAllUsers } from "../api/users";
Vue.use(Vuex);
const state = {
  users: [],
  total:0,
  del:[]
};
const getters = {};
const actions = {
  async getReqPaging({ commit }, { page, limit }) {
    const res = await reqPaging(page, limit);
    commit("GET_REQ_PAGING", res);
  },
  async allReqUsers({ commit }) {
    const res = await reqAllUsers();
    commit("ALL_REQ_USERS", res);
  },

};
const mutations = {
  GET_REQ_PAGING(state, res) {
    state.users = res.data;
  },
  ALL_REQ_USERS(state, res) {
    state.total = res.data.length;
  }
};
export default new Vuex.Store({
  state,
  getters,
  actions,
  mutations,
});
